package com.extremeforce.parser;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.jdom.Element;

import android.graphics.Bitmap;

import com.extremeforce.function.GetNetImage;

public class CouponParser extends IGuangXMLParser{
	private ArrayList<HashMap<String,Object>> list;
	
	public CouponParser(ArrayList<HashMap<String,Object>> list){
		this.list = list;
	}
	
	
	@Override
	public ArrayList<HashMap<String, String>> process(Element records){
		List<Element> recordList = records.getChildren("coupon");
		for(Iterator<Element> iter = recordList.iterator();iter.hasNext();){
			
			Element record = (Element)iter.next();
			String coupon_id = record.getChildText("id");
			String coupon_title = record.getChildText("title");
			String desc = record.getChildText("desc");
			String num = record.getChildText("num");
			String url = record.getChildText("image");
			
			
			HashMap<String,Object> map = new HashMap<String,Object>();
			map.put("id",coupon_id);
			map.put("title",coupon_title);
			map.put("desc",desc);
			map.put("num",num);
			
			Bitmap bitmap = GetNetImage.getImage(url);
			map.put("image",bitmap);			
			list.add(map);
		}
		return null;
	}
}
